float4x4 World;
float4x4 View;
float4x4 Projection;
texture BasicTexture;
bool TextureEnabled = false;
float3 LightDirection = float3(1, -1, 0);
// TODO: add effect parameters here.

struct VertexShaderInput
{
	float4 Position : POSITION;	
	float3 Normal : NORMAL;
	float2 UV : TEXCOORD;
};

struct VertexShaderOutput
{
	float4 Position : POSITION0;
	float2 UV : TEXCOORD0;
	float3 Normal : TEXCOORD1;
};
// Add basic texture
sampler BasicTextureSampler = sampler_state {
	texture = <BasicTexture>;
	AddressU = clamp;
	AddressV = clamp;
	MinFilter = Anisotropic;
	MagFilter = Anisotropic;
	MipFilter = Linear;
};

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    VertexShaderOutput output;

    float4 worldPosition = mul(input.Position, World);
    float4 viewPosition = mul(worldPosition, View);
    output.Position = mul(viewPosition, Projection);
	output.UV =  input.UV;
	output.Normal = input.Normal;
    // TODO: add your vertex shader code here.

    return output;
}

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
    // TODO: add your pixel shader code here.

	float3 output = float3(1, 1, 1);
	float light = dot(normalize(input.Normal), normalize(LightDirection));
	light = clamp(light+0.8f, 0, 1);
	if (TextureEnabled)
		output *= tex2D(BasicTextureSampler, input.UV);
	return float4(output*light , 1);
}

technique Technique1
{
    pass Pass1
    {
        // TODO: set renderstates here.
        VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 PixelShaderFunction();
    }
}
